#include "MathAndPhysics.h"
#include <PA9.h>
Vector2D::Vector2D(Vector2D unitVector, float magnitude)
:x(unitVector.x),y(unitVector.y)
{
	normalise();
	(*this)*magnitude;
};
	
void Vector2D::normalise()
{
	float length = PA_TrueDistance(0,0,x,y);
	x = x/length;
	y = y/length;
}
float Vector2D::length()
{
	return PA_TrueDistance(0,0,x,y);
}
Vector2D operator- (const Vector2D& x, const Vector2D& y)
{
	return Vector2D(x.x-y.x,x.y-y.y);
}
Vector2D Vector2D::operator= (const Vector2D& x)
{
	this->x = x.x;
	this->y = x.y;
	return *this;
}

Vector2D operator+ (const Vector2D& x, const Vector2D& y)
{
	return Vector2D(x.x+y.x,x.y+y.y);
}
Vector2D operator* (const Vector2D& x, const Vector2D& y)
{
	return Vector2D(x.x*y.x,x.y*y.y);
}

Vector2D operator+ (const Vector2D& x, const float& y)
{
	return Vector2D(x.x+y,x.y+y);
}
Vector2D operator* (const Vector2D& x, const float& y)
{
	return Vector2D(x.x*y,x.y*y);
}

Vector2D operator+ (const float& x, const Vector2D& y)
{
	return Vector2D(x+y.x,x+y.y);
}
Vector2D operator* (const float& x, const Vector2D& y)
{
	return Vector2D(x*y.x,x*y.y);
}
